package cn.jinjie.day04.test01;

public class Demo2 {
    public static void main(String[] args) {
        Swimming s1 = new Swimming() {
            @Override
            public void swim() {
                System.out.println("蛙泳");
            }
        };
        goSwim(s1);//匿名内部类，不用创建接口实现类的对象
        goSwim(new Swimming() {
            @Override
            public void swim() {
                System.out.println("自由泳");
            }
        });
    }

    public static void goSwim(Swimming s) {
        s.swim();
    }
}
